package com.bytecodezz.app.base.extend.activity

import androidx.appcompat.app.AppCompatActivity
import androidx.navigation.fragment.NavHostFragment

/************ 获取当前NavHost显示的是否都是目标Fragment ************/
fun <F> AppCompatActivity.isCurrentNavHostFragment(fragmentClass: Class<F>): Boolean {
    val navHostFragment = this.supportFragmentManager.fragments.first() as NavHostFragment
    navHostFragment.childFragmentManager.fragments.forEach {
        if (fragmentClass.isAssignableFrom(it.javaClass)) {
//            return it as F
            return true
        }
    }
    return false
}